<include file='Public:head'/>
<include file='Public:header'/>
<script>
    function edititem(name,definition){
      $('#edititemname').val(name);
      $('#editdefinition').html(definition);
    }

    function addExample (i_id, itemname) {
      $('#addExampleIid').val(i_id);
      $('#addExampleItemname').val(itemname);
    }
</script>
    <div class="container" style="margin-top:60px;">
        <div class="row text-center">    
            <form class="form-search" method="post" action="{:U(GROUP_NAME . '/Person/work_platform', array('d_id' => $item[0]['d_id'] ))}">
<!--               <div class="input-append">
                <label for="">在{$title}中搜索词条：</label>
              </div> -->
              <div class="input-append">
                <input type="text" class="span4 search-query input-large" name="s" value="{$s}" required>
                <button type="submit" class="btn">Search</button>
              </div>
            </form>
        </div>
        <div class="row">
            <div class="span12">
                <h3 class="text-left"><a href="__ACTION__/d_id/{$item[0].d_id}">{$doc.docname}</a></h3>
                <div class="thumbnail">
                  <div class="accordion" id="accordion2">
                    <volist name="item" id="i">
                      <div class="accordion-group">
                        <div class="accordion-heading">
                          <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion2" href="#collapseWord{$i.i_id}">
                            {$i.itemname}
                          </a>
                        </div>
                        <div id="collapseWord{$i.i_id}" class="accordion-body collapse" style="height: 0px;">
                          <div class="accordion-inner">
                            <div>
                              <strong>Definition：</strong>{$i.definition}                  
                              <span class="pull-right">
                                <a href="#modalEditItem" data-toggle="modal"><i onclick="edititem('{$i.itemname}','{$i.definition}')" class="icon-edit"></i></a>
                                <a href="{:U(GROUP_NAME . '/Person/deleteItemHandle', array('i_id' => $i['i_id']))}" onclick="return confirm('确定将此词条删除?')"><i class="icon-remove"></i></a>
                              </span>
                            </div>
                            <p>
                              <strong>In：</strong> 
                              <a href="">{$i.Document.docname}</a>
                            </p>
                            <div class="bs-docs-example">
                              <p class="text-right">
                                <a href="#modalAddExample" data-toggle="modal" onclick="addExample('{$i.i_id}', '{$i.itemname}')">Add Example</a>
                              </p>
                              <volist name="i['Example']" id="e">
                                <div class="thumbnail">
                                  {$e.sentence}
                                </div>
                              </volist>
                            </div>
                          </div>
                        </div>
                      </div> 
                    </volist>
                  </div>
                    
                  <div class="pagination pagination-centered">
                    <ul>
                        <label>当前&nbsp;{$page.nowPage}&nbsp;页/共&nbsp;{$page.totalPages}&nbsp;页</label>
                        <li><a href="__ACTION__/d_id/{$item[0].d_id}/p/{$page.firstPage}">第一页</a></li>
                        <li><a href="__ACTION__/d_id/{$item[0].d_id}/p/{$page.prePage}">上一页</a></li>
                        <li><a href="__ACTION__/d_id/{$item[0].d_id}/p/{$page.nextPage}">下一页</a></li>
                        <li><a href="__ACTION__/d_id/{$item[0].d_id}/p/{$page.totalPages}">最后一页</a></li>
                      </ul>
                  </div>

                </div>
            </div>
            
        </div>
    </div>
<include file='Public:footer/'>

<!-- 编辑词条 -->
<div id="modalEditItem" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">编辑词条</h3>
  </div>
  <form class="form-horizontal" method="post" action="{:U(GROUP_NAME . '/Person/updateItemHandle')}">
    <div class="modal-body">
      <div class="control-group">
        <label class="control-label" for="itemname">词条</label>
        <div class="controls">
          <input type="text" id="edititemname" name="itemname" placeholder="词条" required>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="definition">释义</label>
        <div class="controls">
          <textarea name="definition" id="editdefinition" rows="10" placeholder="释义"></textarea>
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
      <input type="submit" class="btn btn-primary" value="保存更改">
    </div>
  </form>
</div>

<!-- 添加词条 -->
<div id="modalAddItem" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">添加词条</h3>
  </div>
  <form class="form-horizontal" method="post" action="{:U(GROUP_NAME . '/Person/addItemHandle')}">
    <div class="modal-body">
      <div class="control-group">
        <label class="control-label" for="itemname">词条</label>
        <div class="controls">
          <input type="text" id="additemname" name="itemname" placeholder="词条" required>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="definition">释义</label>
        <div class="controls">
          <textarea name="definition" id="adddefinition" rows="10" placeholder="释义"></textarea>
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
      <input type="submit" class="btn btn-primary" value="添加">
    </div>
  </form>
</div>

<!-- 添加词条 -->
<div id="modalAddExample" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">添加例子</h3>
  </div>
  <form class="form-horizontal" method="post" action="{:U(GROUP_NAME . '/Person/addExampleHandle')}">
    <div class="modal-body">
    <input type="hidden" name="i_id" id="addExampleIid">
      <div class="control-group">
        <label class="control-label">所属词条</label>
        <div class="controls">
          <input type="text" id="addExampleItemname" readonly="true">
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="sentence">例句</label>
        <div class="controls">
          <textarea name="sentence" id="sentence" cols="30" rows="5" placeholder="例句" required></textarea>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label" for="definition">释义</label>
        <div class="controls">
          <textarea name="definition" id="adddefinition" rows="10" placeholder="释义" required></textarea>
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
      <input type="submit" class="btn btn-primary" value="添加">
    </div>
  </form>
</div>



<style>
  .myul li{
    display: block;
    width: 95%;
    border-radius: 3px;
    border: 1px dashed #ccc;
    height: auto;
    line-height: 40px;
    margin-top: 8px;
    padding:10px;
    padding-left: 8px;
    color: gray;
    font-size: 18px;
    background: #eee;
  }
  .tArea{
    height: 550px;
    width: 610px;
  }
</style>